package Synchronized;

import java.util.Scanner;


public class demo4 {
    static class Counter {
        public volatile int count = 0;
    }
    public static void main(String[] args) throws InterruptedException {

        Counter counter = new Counter();
        Thread t1 = new Thread(()->{
            while(counter.count == 0)
            {

            }
            System.out.println(Thread.currentThread().getName()+"接到通知，马上停下来...");
        },"t1");
        Thread t2 = new Thread(()->{
            Scanner sc = new Scanner(System.in);
            System.out.println(Thread.currentThread().getName()+"发出停止通知...");
            counter.count = sc.nextInt();

        },"t2");
     t1.start();
     t2.start();


    }

}
